module.exports = {  
 
  configureWebpack:{
    devServer:{
      //Mock接口编写的地方
      //每次修改这个配置文件的时候，都要重启项目才生效
      before(app){
        // app.get('请求地址',(req,res)=>{
        //   res.json({
        //     aaaaaaa
        //   })
        // })
        //注册接口，模拟用户数据库信息池
        let userpoor=[
          {username:'tjt',password:'123456'},
          {username:'czz',password:'123456'}
        ]
        app.get('/api/register',(req,res)=>{
          const {username,password}=req.query
          const userlength=userpoor.filter(v=>v.username==username).length
          if(userlength>0){
            res.json({
              success:false,
              message:'用户名已存在'
            })
          }else{
            res.json({
              success:true,
              message:'注册成功'
            })
          }
        })

        //登录接口
        let tokenkey='xdclass'
        app.get('/api/login',(req,res)=>{
          const{username,password}=req.query
          if(username=='tjt' && password=='123456' || username=='czz' && password=='123456'){
            res.json({
              code:0,
              message:'登录成功',
              token:tokenkey+'-'+username+'-'+(new Date().getTime()+60*60*1000)
            })
          }else{
            res.json({
              code:1,
              message:'账号或密码错误'
            })
          }
        })

        //首页轮播图接口
        app.get('/api/banner',(req,res)=>{
          res.json({
            data:[
              {
                url:'https://m.xdclass.net',
                image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg'
              },
              {
                url:'https://m.xdclass.net',
                image:'https://xdvideo-file.oss-cn-shenzhen.aliyuncs.com/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/ms.png'
              },
              {
                url:'https://m.xdclass.net',
                image:'https://xdvideo-file.oss-cn-shenzhen.aliyuncs.com/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/python.png'
              }
            ]
          })
        })

        //滚动分类接口
        app.get('/api/rollinglist',(req,res)=>{
          res.json({
            data:[
              [
                {
                url:'https://m.xdclass.net',
                image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                }  
              ],
              [
                {
                url:'https://m.xdclass.net',
                image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                url:'https://m.xdclass.net',
                image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                },
                {
                  url:'https://m.xdclass.net',
                  image:'https://file.xdclass.net/video/%E5%AE%98%E7%BD%91%E8%BD%AE%E6%92%AD%E5%9B%BE/22lbt-ssm.jpeg',
                  lable:'分类一'
                }                
              ]
            ]
          })
        })


      }
    }
  },

  css: {
    loaderOptions: {
      stylus: {
        "resolve url": true,
        import: ["./src/theme"]
      }
    }
  },
  pluginOptions: {
    "cube-ui": {
      postCompile: true,
      theme: true
    }
  }
}
